package com.ruoyi.app.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.customerapply.domain.CrmCustomerApply;
import com.ruoyi.customerapply.service.ICrmCustomerApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 客户申请Controller
 * 
 * @author hct
 * @date 2022-02-16
 */
@RestController
@RequestMapping("/app/customerApply")
public class AppCustomerApplyController extends BaseController
{
    @Autowired
    private ICrmCustomerApplyService crmCustomerApplyService;

    /**
     * 查询客户申请列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CrmCustomerApply crmCustomerApply)
    {
        startPage();
        crmCustomerApply.setStatus(0);
        List<CrmCustomerApply> list = crmCustomerApplyService.selectCrmCustomerApplyList(crmCustomerApply);
        return getDataTable(list);
    }

    /**
     * 获取客户申请详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(crmCustomerApplyService.selectCrmCustomerApplyById(id));
    }

    /**
     * 新增客户申请
     */
    @PostMapping("/apply")
    public AjaxResult apply( CrmCustomerApply crmCustomerApply)
    {
        crmCustomerApply.setStatus(0);
        return toAjax(crmCustomerApplyService.insertCrmCustomerApply(crmCustomerApply));
    }

    /**
     * 修改客户申请
     */
    @PostMapping("edit")
    public AjaxResult edit( CrmCustomerApply crmCustomerApply)
    {
        return toAjax(crmCustomerApplyService.updateCrmCustomerApply(crmCustomerApply));
    }


}
